import java.util.Scanner;
public class Work_4 {
    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        System.out.println("请输入阶乘尾数n");
        int n = reader.nextInt();
        System.out.println(Factorial(n));
    }

    public static int Factorial(int n) {
        int a = 0;
        for (int i = 1; i <= n; i++) {
            int b = 1;
            for (int j = 1; j <= i; j++) {
                b = b * j;
                a += b;
            }
        }
        return a;
    }
}



